home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 30 / Mac Magazin and MacEasy Magazine CD - Issue 30.iso / online / Mac OS / SolscapePPC ƒ.sit / SolscapePPC ƒ / Scripting Examples < prev    next >
Text File  |  2001-07-09  |  6KB  |  145 lines

  1. tell application "Finder"
  2.     --Since I don't know the name of your startup disk, I'll let the Finder tell me
  3.     set DiskName to name of startup disk
  4.     --We will use the variable DiskName below when saving an image to the desktop.
  5. end tell
  6.  
  7.  
  8.  
  9. tell application "Solscape" --Note; change this to Solscape X for the carbon version.
  10.     
  11.     ------------------------------------
  12.     ------Solscape Functions-----
  13.     ------------------------------------
  14.     
  15.     --IMPORTANT:
  16.     --We MUST wait until Solscape is loaded and ready
  17.     --The variable isReady will be "false" until Solscape is loaded. Always loop
  18.     --until isReady is true at the begining of a script. If Solscape isn't loaded and ready,
  19.     --all AppleEvents will be ignored.
  20.     
  21.     repeat while not (isReady)
  22.     end repeat --When Solscape is ready, the loop is quit
  23.     
  24.     if isOffline then --we can check the offline status of Solscape with the isOffline variable.
  25.         GoOnline --Set offline status to false, I.E, go online.
  26.     end if
  27.     
  28.     --Now lets download Sun Image number 1, EIT 304. Items are indexed, the number is next to the item in the Item list.
  29.     GetSunImage 1
  30.     
  31.     -- Now we wait until the download is finished
  32.     repeat while isDownloading
  33.     end repeat
  34.     
  35.     --Once finished, the script exits the loop. Now we can safely save the picture.
  36.     --To do this, we must specify which item to save, and then send a file path and file name to save the image as.
  37.     set ErrorNum to SaveSunImage 1 in (DiskName & ":Desktop Folder:EIT_304_Image.jpg")
  38.     --We must also receive an integer as a reply to this command. This is an Error Code:
  39.     -- 0 - No Error : 1 - Bad Path : 2 - Item exists as directory : 3 - No such image number : 4 - Unknown Error
  40.     --So if sucsessful, ErrorNum would be 0
  41.     
  42.     
  43.     ------------------------------------
  44.     ------Solscape Variables------
  45.     ------------------------------------
  46.     
  47.     --Here are examples of how to get data out of Solscape:
  48.     
  49.     set ITemp to ionTemperature --Returns a String
  50.     set SSCount to sunspotCount --Returns a String
  51.     set PDens to protonDensity --Returns a String 
  52.     set SWnd to solarWind --Returns a String
  53.     set RFlux to radioFlux --Returns a String
  54.     set NReg to newRegions --Returns a String
  55.     set XFlux to xrayFlux --Returns a String
  56.     
  57.     --For Flares, you must specify what type of flare data you want. Xray Flares are strings, Optical are integers
  58.     set xFlare to flareXRay type "C" --Returns a String
  59.     set oFlare to flareOptical type 1 --Returns a String
  60.     
  61.     set SRise to todaysSunrise --Returns a String
  62.     set SSet to todaysSunset --Returns a String
  63.     
  64.     set AEvent to auroraEvent --Returns an Integer, 0-Unknown, 1-low,2-medium,3-high
  65.     
  66.     set MDNew to moonDaysUntilNew --Returns an integer
  67.     set MDFull to moonDaysUntilFull --Returns an integer
  68.     
  69.     ------------------------------------
  70.     ------Setting Preferences-----
  71.     ------------------------------------
  72.     
  73.     --To set the backup folder for saving automatic backups, send an alias or path to Solscape.
  74.     --Setting the backup folder for saving copies of all downloads requires you to receive an integer reply. This is an
  75.     --error code flag.The error codes are 0 - No Error : 1 - Bad Path : 2 - Item already exists as file : 3 - Unknown Error
  76.     
  77.     set ErrorNum to SetBackupFolder (DiskName & "Desktop Folder:Solscape Downloads")
  78.     --"ErrorNum" should be zero. If not, an error occured.
  79.     --Also, If the backup folder does not exist, it will be created.
  80.     
  81.     (*
  82.     For setting item options, each item is referenced by a number. This is the number next to the item in
  83.     the Item list, or in the popup menu for Alerts and Weather.
  84.     
  85.     This next function sets the automatic download period for sun image number 1, EIT 304.
  86.     Download periods are integers, from 0 to 12.
  87.     The numbers correspond to:
  88.     0: Manual
  89.     1: 2  Minutes
  90.     2: 5 Minutes
  91.     3: 10 Minutes
  92.     4: 15 Minutes
  93.     5: 30 Minutes
  94.     6: 45 Minutes
  95.     7: 1 hour
  96.     8: 1 1/2 hours
  97.     9: 2 hours
  98.     10: 4 hours
  99.     11: 8 hours
  100.     12: 12 hours
  101.     *)
  102.     SetSunDownloadPeriod 1 to 5
  103.     --This sets EIT 304 to automatically download every 30 minutes
  104.     
  105.     (* 
  106.     This next function sets the Data Plot Period for ACE graphs.
  107.     Again, the plot period is an integer code, from 0 to 4:
  108.     0: 2 Hour
  109.     1: 6 Hour
  110.     2: 24 Hour
  111.     3: 3 Day
  112.     4: 7 Day
  113.     *)
  114.     SetDataPlotPeriod 3 to 1
  115.     -- So therefore, this command sets the ACE Protons and Electrons graph plot period to 6 hours.
  116.     
  117.     --In order to set the flags for including items in Update All and Save Backup Copy, we must pass both a number and a STRING,
  118.     -- not a boolean. Sorry, but the Applescript handling of sending a boolean as a second parameter is a bit weird and it
  119.     --was very counter intuitive. Here is an example of how to set Sun Image 3 (EIT 195) to be included in the Update All feature:
  120.     SetUpdateAllSun 3 to "true"
  121.     
  122.     --You can use "True" or "Yes", or "False" or "No".
  123.     
  124.     -- Here is another example that sets the backup option of Earth Image 12 (Eastern US Visible) to false:
  125.     SetSaveEarthBackup 12 to "no" --we could also say "false"
  126.     
  127.     
  128.     ------------------------------------
  129.     ---Controlling the Interface---
  130.     ------------------------------------
  131.     
  132.     --This next command sets the panel to the desired number. In this case, the Aurora Panel.
  133.     GotoPanel 3
  134.     
  135.     --This next command sets the current item selection. In this case, the current Aurora selection is
  136.     --set to number 4, the Ultraviolet Imager graph.
  137.     SetAuroraItem 4
  138.     
  139.     
  140.     --This next method opens the Aurora Event Probability floating window
  141.     DisplayAuroraAlert
  142.     --If you only want to display the Aurora window if there is a high chance for an event, add "with HighOnly" to the end
  143.     --of the command, like "DisplayAuroraAlert with HighOnly"
  144.     
  145. end tell